package bavaria.hightech.banking.gui;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 * A panel that is displayed in the contentWrapper JPanel. displays the balance
 * of the current account
 * 
 * @author Dietmar
 */
public class PanelBalance {

	private GlobalVarsContainer cont;

	public PanelBalance(GlobalVarsContainer cont) {
		this.cont = cont;
	}

	public JPanel getJPanel() {

		JLabel reviewLabel = new JLabel();
		JPanel panel = new JPanel();
		JLabel label = new JLabel("Your balance is:");

		try {
			reviewLabel.setText(cont.getBank().getBalance(cont.getSelAccNr())
					+ "");
		} catch (IllegalStateException e) {
			reviewLabel.setText("> select a valid account number first ("
					+ cont.getSelAccNr() + ") <");
		}

		reviewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		reviewLabel.setVerticalAlignment(SwingConstants.CENTER);
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setVerticalAlignment(SwingConstants.CENTER);
		// label.setFont(new Font("sansserif", Font.BOLD, 12));

		panel.add(label);
		panel.add(reviewLabel);

		return panel;
	}

}
